﻿package mortal.game.view.forging.view
{
    import __AS3__.vec.*;
    import com.gengine.utils.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import fl.data.*;
    import flash.display.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.forging.renderer.*;
    import mortal.game.view.palyer.*;

    public class EquipColorInfoView extends GSprite
    {
        private var _advancedEquip:PlayerEquipItem;
        private var attrVec:Vector.<EquipColorAttrData>;
        private var _nameDesc:GTextFiled;
        private var _equipCombat:BitmapNumberText;
        private var _attrList:GTileList;
        private var _equipReviewImg:GImageBitmap;
        private var _reviewText:GTextFiled;
        private var _colorDesc:GTextFiled;
        private var _isCurrColor:Boolean;

        public function EquipColorInfoView()
        {
            this.attrVec = new Vector.<EquipColorAttrData>;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(55, 0, 72, 27, this, ImagesConst.CombatTextBg));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.TextBg3, -20, 162, this));
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.size = 14;
            this._colorDesc = UIFactory.gTextField("", 74, 0, 36, 30, this, _loc_1);
            var _loc_2:* = GlobalStyle.textFormatBai;
            _loc_2.align = AlignMode.CENTER;
            _loc_2.size = 14;
            this._nameDesc = UIFactory.gTextField("", -12, 165, 210, 25, this, _loc_2);
            this._advancedEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            this._advancedEquip.setItemStyle(ItemStyleConst.Big, "", 6, 6);
            this._advancedEquip.x = 55;
            this._advancedEquip.y = 67;
            this.addChild(this._advancedEquip);
            this._advancedEquip.isShowArroundEffect = false;
            this._equipReviewImg = UIFactory.gImageBitmap("", 72 + 2, (82 + 1), this);
            var _loc_3:* = GlobalStyle.textFormatLv;
            _loc_3.size = 14;
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.AttributeBg, 0, 197, this));
            this.pushUIToDisposeVec(UIFactory.bg(14, 207, 159, 23, this, ImagesConst.RegionTitleBg));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_Text_EquipCombat, 48, 210, this));
            this._equipCombat = UIFactory.bitmapNumberText(105, 211, "FightInfoNum.png", 12, 15, -1, this);
            this._reviewText = UIFactory.gTextField("？ ？ ？", 105, 208, 100, 20, this, GlobalStyle.textFormatHuang);
            var _loc_4:int = 0;
            while (_loc_4 < 3)
            {
                
                _loc_5 = 29;
                _loc_6 = 256 + _loc_4 % 3 * 19;
                this.pushUIToDisposeVec(UIFactory.bg(_loc_5, _loc_6, 135, 0, this, ImagesConst.PropSplitLine));
                _loc_4++;
            }
            this._attrList = UIFactory.tileList(58, 238, 170, 60, this);
            this._attrList.columnWidth = 168;
            this._attrList.rowHeight = 19;
            this._attrList.horizontalGap = 0;
            this._attrList.verticalGap = 0;
            this._attrList.setStyle("skin", new Bitmap());
            this._attrList.setStyle("cellRenderer", ColorAdvanceAttrCellRenderer);
            return;
        }// end function

        public function updateColorInfo(param1:ItemData) : void
        {
            if (param1 != null)
            {
                this._advancedEquip.itemData = param1;
                this.updateColorDesc();
                this.updateEquipDesc();
                this.updateAttr();
                if (this._equipReviewImg.visible)
                {
                    this._equipReviewImg.visible = false;
                }
                if (this._reviewText.visible)
                {
                    this._reviewText.visible = false;
                }
            }
            else
            {
                this.clearUI();
            }
            return;
        }// end function

        private function updateBg() : void
        {
            var _loc_1:* = this._advancedEquip.itemData.itemInfo.color;
            switch(_loc_1)
            {
                case ForgingConst.EquipColor_Lv:
                {
                    break;
                }
                case ForgingConst.EquipColor_Lan:
                {
                    break;
                }
                case ForgingConst.EquipColor_Zi:
                {
                    break;
                }
                case ForgingConst.EquipColor_Cheng:
                {
                    break;
                }
                case ForgingConst.EquipColor_Hong:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function updateColorDesc() : void
        {
            var _loc_1:* = ColorConfig.instance.getItem("item", this._advancedEquip.itemData.itemInfo.color + "").color;
            var _loc_2:* = ColorConfig.instance.getItem("item", this._advancedEquip.itemData.itemInfo.color + "").colorText;
            this._colorDesc.htmlText = HTMLUtil.addColor(_loc_2, _loc_1);
            return;
        }// end function

        private function updateEquipDesc() : void
        {
            var _loc_1:* = ItemsUtil.getItemWholeName(this._advancedEquip.itemData, true, 0, false);
            this._nameDesc.htmlText = _loc_1;
            return;
        }// end function

        public function updateEquipCombat(param1:int) : void
        {
            if (this._advancedEquip.itemData)
            {
                this._equipCombat.text = param1 + "";
                this._advancedEquip.itemData.extInfo.combat = param1;
            }
            else
            {
                this._equipCombat.text = "";
            }
            return;
        }// end function

        private function updateAttr() : void
        {
            var _loc_3:AttributeData = null;
            var _loc_4:EquipColorAttrData = null;
            var _loc_5:String = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = EquipmentUtil.getStrengthenAttr(this._advancedEquip.itemData, true);
            for each (_loc_3 in _loc_2)
            {
                
                _loc_4 = new EquipColorAttrData();
                _loc_5 = GameDefConfig.instance.getAttributeName2(_loc_3.name);
                _loc_4.attrEgName = _loc_3.name;
                _loc_4.attrName = _loc_5;
                _loc_4.attrValue = _loc_3.value;
                _loc_1.addItem(_loc_4);
            }
            this._attrList.dataProvider = _loc_1;
            this._attrList.drawNow();
            return;
        }// end function

        public function set isCurrColor(param1:Boolean) : void
        {
            this._isCurrColor = param1;
            if (param1)
            {
                this._equipReviewImg.imgUrl = ImagesConst.Forging_PutInEquip;
                this._equipReviewImg.x = 74;
                this._equipReviewImg.y = 83;
            }
            else
            {
                this._equipReviewImg.imgUrl = ImagesConst.Forging_ColorViewText;
                this._equipReviewImg.x = 71;
                this._equipReviewImg.y = 81;
            }
            return;
        }// end function

        public function clearUI() : void
        {
            this._advancedEquip.itemData = null;
            this._nameDesc.text = "";
            this._equipCombat.text = "";
            this._colorDesc.text = "";
            var _loc_1:* = new DataProvider();
            this._attrList.dataProvider = _loc_1;
            this._attrList.drawNow();
            this._equipReviewImg.visible = true;
            this._reviewText.visible = true;
            return;
        }// end function

        public function get advancedEquip() : PlayerEquipItem
        {
            return this._advancedEquip;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._nameDesc.dispose(param1);
            this._advancedEquip.dispose(param1);
            this._equipCombat.dispose(param1);
            this._attrList.dispose(param1);
            this._equipReviewImg.dispose(param1);
            this._reviewText.dispose(param1);
            this._colorDesc.dispose(param1);
            this._nameDesc = null;
            this._advancedEquip = null;
            this._equipCombat = null;
            this._attrList = null;
            this._equipReviewImg = null;
            this._reviewText = null;
            this._colorDesc = null;
            this.attrVec.length = 0;
            return;
        }// end function

    }
}
